#!/bin/bash

# 定义变量方便修改
table_db=cy_database 
hive=/home/software/hive-2.3.6/bin/hive

# 如果是输入的日期按照取输入日期；如果没输入日期取当前时间的前一天
if [ -n "$1" ] ;then
	do_date=$1
else 
	do_date=`date -d "-1 day" +%F`  
fi 

sql="
with
tmp_enterprise_probation_years as (
	select
		id,
		ent_id,
		ent_name,
		business_nature_code ,
		business_nature,
		plan_probation_total ,
		actual_probation_total ,
		probation_retain ,
		already_provide_alimony,
		already_probation_subsidy,
		probation,
		credit_code ,
		updated_time
	from cy_database.dwd_enterprise_probation_years epy
	where epy.dt='2020-06-17' and epy.id is not null

)

insert overwrite table cy_database.dws_enterprise_probation_years partition(dt='2020-06-17')
	select
		id,
		ent_id,
		ent_name,
		business_nature_code ,
		business_nature,
		plan_probation_total ,
		actual_probation_total ,
		probation_retain ,
		already_provide_alimony,
		already_probation_subsidy,
		probation,
		credit_code ,
		updated_time
	from tmp_enterprise_probation_years

;



"
$hive -e "$sql"